<h2>Edit an article</h2>

<form method="post" action="">
	
    <div class="error">@Page.Errors</div>
    <fieldset><legend>
        Add article
	</legend>
    <table>
        <tr>
            <th><label for="title" >Title : </label></th>
            <td><input type="text" name="title" value="@(IsPost?Request.Form["title"]:PageData["Article"].title)" size="55"/></td>
        </tr>
        <tr>
            <th><label for="summary">Summary : </label></th>
            <td>
                <textarea id="TinyArea" name="summary" rows="5" cols="80" style="width: 100%">
                @(IsPost?Request.Form["summary"]:PageData["Article"].summary)
                </textarea>
             </td>
        </tr>
        <tr>
            <th><label for="content">Content : </label></th>
            <td>
                <textarea id="TinyArea1" name="content" rows="15" cols="80" style="width: 100%">
                @(IsPost?Request.Form["content"]:PageData["Article"].content)
                </textarea>
             </td>
        </tr>
        <tr>
            <th>Date of creation</th>
            <td>@Html.TextBox("creationDate",IsPost?Request.Form["creationDate"]:PageData["Article"].creationDate.ToString("yyyy/M/d HH:MM:ss"))</td>
		</tr>
        <tr>
            <th>@Html.Hidden("articleId",IsPost?Request.Form["articleId"]:PageData["Article"].id)</th>
            <td><input type="checkbox" name="published" value="1" @(((IsPost && Request.Form["published"]=="1")||(!IsPost && PageData["Article"].published==1))?"checked":"")/><label for="content"> Published</label></td>
		</tr>
       <tr>
            <th></th>
            <td><input type="checkbox" name="enableComments" value="1" 
                 @(  (( IsPost && Request.Form["enableComments"]=="1" ) || ( !IsPost && PageData["Article"].enableComments == 1 )) ?"checked":" ") 
            /><label for="enableComments"> Enable Commenting</label></td>
		</tr>
        <tr>
            <th></th>
            <td><input type="checkbox" name="showComments" value="1"  @( (IsPost && Request.Form["showComments"].AsInt()==1) || (!IsPost && PageData["Article"].ShowComments == 1) ?"checked":" ")  /><label for="showComments"> Show Comments</label></td>
		</tr>
        <tr>
            <th>Category : </th>
            <td><select name="categoryId">
       
                <option value="">Select a category</option>
                @{
                    var currentCategoryId = IsPost?Request.Form["categoryId"].AsInt():PageData["Article"].categoryId;
				}
                @foreach(var category in PageData["Categories"]){
                    <option value="@category.id" 
                    @if(category.id == currentCategoryId)
                    {
                            <text>selected</text>
                    }
                     >@category.name</option>
                }
                </select>
            </td>
		</tr>
        <tr>
            <th class="case"></th>
            <td><input type="submit" name="submit" value="Submit" /><input type="reset" name="reset" value="Reset" /></td>
		</tr>


    </table></fieldset>
	
	
</form>